package com.thymeleaf;

import domain.Actor;
import myspringmvc.ViewBaseServlet;
import service.ActorService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/edit.do")
public class ActorEdit extends ViewBaseServlet {

    private ActorService actorService = new ActorService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String idStr = req.getParameter("id");
        System.out.println(idStr);
        if (idStr != null && !"".equals(idStr)) {
            int id = Integer.parseInt(idStr);
            Actor info = actorService.getInfo(id);
            req.setAttribute("actor", info);
            super.processTemplate("edit",req,resp);
        }
    }
}
